# 导包
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

driver = webdriver.Firefox()
driver.maximize_window()
url = 'file:///C:/Users/tedu/Desktop/NSD2407/html/register.html'
driver.get(url)
# 需求：
#  1. 打开register.html
#  2. 点击 注册A网页
#  3. 填写 注册A网页 内容
sleep(3)
driver.find_element(By.PARTIAL_LINK_TEXT, 'A网页').click()
# 窗口句柄：用来识别不同的窗口，类似ID
# 获取主窗口句柄
main_handle = driver.current_window_handle
print('主窗口：', main_handle)
# 获取所有窗口句柄
handles = driver.window_handles
print('所有窗口：', handles)
# 切换到A网页
for item in handles:
    if item != main_handle:
        # print('新窗口句柄：', item)
        driver.switch_to.window(item)
        print('标题：', driver.title)

        driver.find_element(By.CSS_SELECTOR, '#userA').send_keys('admin')
        driver.find_element(By.CSS_SELECTOR, '#passwordA').send_keys('123456')
        driver.find_element(By.CSS_SELECTOR, '#telA').send_keys('17312345678')
        driver.find_element(By.CSS_SELECTOR, '#emailA').send_keys('admin@qq.com')

sleep(3)
driver.quit()